﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Text;
using XiuxianGame.DBOper;

namespace XiuxianGame.人物
{
    public class Player
    {
        static Player player;
        DataTable dt;
        DataTable npcdt;
        //背包
        int beibaodaxiao;
        int[] wupins;

        public Player()
        {
            
        }

        //DB操作
        static PlayerOper dbp = new PlayerOper();

        public int Id { get => (int)(Double)dt.Rows[0]["id"]; set => dt.Rows[0]["id"] = value * 1.0f; }
        public string Name { get => (string)dt.Rows[0]["name"]; set => dt.Rows[0]["name"] = (string)value; }
        public string Sex { get => (string)dt.Rows[0]["sex"]; set => dt.Rows[0]["sex"] = (string)value; }
        public int Age { get => (int)(Double)dt.Rows[0]["age"]; set => dt.Rows[0]["age"] = value * 1.0f; }
        public int Maxage { get => (int)(Double)dt.Rows[0]["maxage"]; set => dt.Rows[0]["maxage"] = value * 1.0f; }
        public int Meili { get => (int)(Double)dt.Rows[0]["meili"]; set => dt.Rows[0]["meili"] = value * 1.0f; }
        public int Djingjie { get => (int)(Double)dt.Rows[0]["djingjie"]; set => dt.Rows[0]["djingjie"] = value * 1.0f; }
        public int Xjingjie { get => (int)(Double)dt.Rows[0]["xjingjie"]; set => dt.Rows[0]["xjingjie"] = value * 1.0f; }
        public int Jingyan { get => (int)(Double)dt.Rows[0]["jingyan"]; set => dt.Rows[0]["jingyan"] = value * 1.0f; }
        public int Hp { get => (int)(Double)dt.Rows[0]["hp"]; set => dt.Rows[0]["hp"] = value * 1.0f; }
        public int Maxhp { get => (int)(Double)dt.Rows[0]["maxhp"]; set => dt.Rows[0]["maxhp"] = value * 1.0f; }
        public int Mp { get => (int)(Double)dt.Rows[0]["mp"]; set => dt.Rows[0]["mp"] = value * 1.0f; }
        public int Maxmp { get => (int)(Double)dt.Rows[0]["maxmp"]; set => dt.Rows[0]["maxmp"] = value * 1.0f; }
        public int Tp { get => (int)(Double)dt.Rows[0]["tp"]; set => dt.Rows[0]["tp"] = value * 1.0f; }
        public int Maxtp { get => (int)(Double)dt.Rows[0]["maxtp"]; set => dt.Rows[0]["maxtp"] = value * 1.0f; }
        public int Actnum { get => (int)(Double)dt.Rows[0]["actnum"]; set => dt.Rows[0]["actnum"] = value * 1.0f; }
        public int Defnum { get => (int)(Double)dt.Rows[0]["defnum"]; set => dt.Rows[0]["defnum"] = value * 1.0f; }
        public double Baolinum { get => (double)dt.Rows[0]["baolinum"]; set => dt.Rows[0]["baolinum"] = value * 1.0f; }
        public double Baojiact { get => (double)dt.Rows[0]["baojiact"]; set => dt.Rows[0]["baojiact"] = value * 1.0f; }
        public int Jin { get => (int)(Double)dt.Rows[0]["jin"]; set => dt.Rows[0]["jin"] = value * 1.0f; }
        public int Mu { get => (int)(Double)dt.Rows[0]["mu"]; set => dt.Rows[0]["mu"] = value * 1.0f; }
        public int Shui { get => (int)(Double)dt.Rows[0]["shui"]; set => dt.Rows[0]["shui"] = value * 1.0f; }
        public int Huo { get => (int)(Double)dt.Rows[0]["huo"]; set => dt.Rows[0]["huo"] = value * 1.0f; }
        public int Tu { get => (int)(Double)dt.Rows[0]["tu"]; set => dt.Rows[0]["tu"] = value * 1.0f; }
        public string Maparea { get => (string)dt.Rows[0]["maparea"]; set => dt.Rows[0]["shui"] = (string)value; }
        public Point Mappoint { 
            get => new Point(int.Parse(((string)dt.Rows[0]["maparea"]).Split(",")[0]), 
                int.Parse(((string)dt.Rows[0]["maparea"]).Split(",")[1])); 
            set => dt.Rows[0]["maparea"] = value; 
        }
        public int Money { get => (int)(Double)dt.Rows[0]["money"]; set => dt.Rows[0]["money"] = value * 1.0f; }


        public DataTable Dt { get => dt; set => dt = value; }
        public DataTable Npcdt { get => npcdt; set => npcdt = value; }

        //测试用load
        public static Player load()
        {
            return dbp.getPlayer(1);
        }

        public DataTable getDPlayer()
        {
            dt = dbp.getDPlayer(1);
            return dt;
        }

        public Dictionary<string,Player> getNPC()
        {

            return dbp.getNPC();
        }

    }
}
